package com.eeo.nana_sun_android_ratingbar;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    android.widget.RatingBar ratingBar = (android.widget.RatingBar) findViewById(R.id.ratingbar);
    final TextView textView = (TextView) findViewById(R.id.tv);
    ratingBar.setOnRatingBarChangeListener(new android.widget.RatingBar.OnRatingBarChangeListener() {
      @Override public void onRatingChanged(android.widget.RatingBar ratingBar, float rating,
          boolean fromUser) {
        if(rating==1){
          textView.setText("极差");
        }else if(rating==3){
          textView.setText("一般");
        }else if(rating==5){
          textView.setText("非常好");
        }
      }
    });
  }

}
